------------------------------------------------
--Icetip
--描述: wow提示增强插件.
--作者: 月色狼影
--$Rev: 63 $
--$Id: core.lua 63 2008-06-25 13:52:57Z wolftankk@cwowaddon.com $
------------------------------------------------

local GameTooltip = _G.GameTooltip

Icetip = EVA.Addon:New();
Icetip = EvaHook:New(Icetip)

Icetip.Name = "Icetip";
Icetip_Rev = GetAddOnMetadata("Icetip", "Version");
Icetip.Version = Icetip_Rev.."."..(tonumber(("$Rev: 63 $"):match("%d+")));

--options
function Icetip:GetDefault()
	return {
		scale = 1,
		font = [[Fonts\FRIZQT__.TTF]],

	}
end


function Icetip:OnInitialize()
	IcetipDB = Icetip:GetDefault();
	GameTooltip:SetOwner(UIParent, "ANCHOR_NONE");

	self.leftgametooltip = {};
	self.rightgametooltip = {};

	for i=1, 50 do
		GameTooltip:AddDoubleLine(' ', ' ');
		self.leftgametooltip = _G["GameTooltipTextLeft"..i];
		self.rightgametooltip = _G["GameTooltipTextRight"..i];
	end

	GameTooltip:Show();
	GameTooltip:Hide();
end



function Icetip:OnEnable()
	self:SetScale();
	--self:SetFont();
end

--[[   Hook ]]---



--[[ Functions ]] --
function Icetip:SetScale(reset)
	if reset then
		GameTooltip:SetScale(1);
		ShoppingTooltip1:SetScale(1);
		ShoppingTooltip2:SetScale(1);
	else
		GameTooltip:SetScale(IcetipDB.scale);
		ShoppingTooltip1:SetScale(IcetipDB.scale);
		ShoppingTooltip2:SetScale(IcetipDB.scale);
	end
end

function Icetip:SetFont(reset)
	local font;
	if reset then
		font = "Fonts\\FRIZQT__.TTF";
	else
		font = IcetipDB.font
	end

	if Icetip.leftgametooltip[1]:GetFont() == font then return end

	for i=1, 50 do
		local left = Icetip.leftgametooltip[i]
		local right = Icetip.rightgametooltip[i]
		local _, size, style = left:GetFont()
		left:SetFont(font, size, style)
		local _, size, style = right:GetFont()
		right:SetFont(font, size, style)

	end



end

----[[ EVA ]] ----
Icetip.Init = {
	Enabled = true,
	RequestTypes = {"Event"},
	Events = {"ADDON_LOADED"},
	Commands = {
		{Function = Icetip:OnInitialize()},
		},
}

Icetip.OnEnabled = {
	Enabled = true,
	RequestTypes = {"Event"},
	Events = {"PLAYER_LOGIN"},
	Commands = {
		{Function = Icetip:OnEnable() },
	},
}
	
Icetip:Add(EVA.Block:New(Icetip.Init));
Icetip:Add(EVA.Block:New(Icetip.OnEnabled));
EVA.AddonRegistry:Add(Icetip);